﻿namespace Sustainalytics.LongRunningTaskManager.Service
{
    using System.Net;
    using System.Net.Http;
    using System.Web.Http;
    using System.Web.Http.Cors;

    [EnableCors(origins: "*", headers: "*", methods: "*")]
    [RoutePrefix("api/v1/taskManagerSettings")]
    public class LongRunningTaskManagerSettingsController : ApiController
    {
        [Route("")]
        public HttpResponseMessage Get()
        {
            // get settings
            var settings = LongRunningTaskManagerSettings.FromConfig();

            // create settings DTO
            var settingsDto = new LongRunningTaskManagerSettingsDto(settings);

            return this.Request.CreateResponse(HttpStatusCode.OK, settingsDto);
        }
    }
}
